#ifndef xpack_test_ttyctrl_test_list
#define xpack_test_ttyctrl_test_list
#pragma push_macro("xuser")
#undef  xuser
#define xuser mixc::test_ttyctrl_test_list::inc
#define private public
#include"test/helper.hpp" // 需要放第一
#include"ttyctrl/text_list.hpp"
#undef  private
#pragma pop_macro("xuser")

namespace mixc::test_ttyctrl_test_list{
    xtest("cookie") {
        auto list = inc::text_list{}->count_of_visiable(4)->count(9u);

        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 0u);
        xassert_eq(list->i_bottom, 3u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.down(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 1u);
        xassert_eq(list->i_bottom, 3u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.down(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 2u);
        xassert_eq(list->i_bottom, 3u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.down(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 3u);
        xassert_eq(list->i_bottom, 3u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.down(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 1u);
        xassert_eq(list->i_current, 4u);
        xassert_eq(list->i_bottom, 4u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.down(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 2u);
        xassert_eq(list->i_current, 5u);
        xassert_eq(list->i_bottom, 5u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.down(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 3u);
        xassert_eq(list->i_current, 6u);
        xassert_eq(list->i_bottom, 6u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.down(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 4u);
        xassert_eq(list->i_current, 7u);
        xassert_eq(list->i_bottom, 7u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.down(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 8u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.down(), inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 0u);
        xassert_eq(list->i_bottom, 3u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);




        xassert_eq(list.up(), inc::text_list_rotate);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 8u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.up(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 7u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.up(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 6u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.up(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 5u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.up(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 4u);
        xassert_eq(list->i_current, 4u);
        xassert_eq(list->i_bottom, 7u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.up(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 3u);
        xassert_eq(list->i_current, 3u);
        xassert_eq(list->i_bottom, 6u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.up(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 2u);
        xassert_eq(list->i_current, 2u);
        xassert_eq(list->i_bottom, 5u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.up(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 1u);
        xassert_eq(list->i_current, 1u);
        xassert_eq(list->i_bottom, 4u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.up(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 0u);
        xassert_eq(list->i_bottom, 3u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.up(), inc::text_list_rotate);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 8u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);


        xassert_eq(list.go(10), bstate_t::fail);
        xassert_eq(list.go(9), bstate_t::fail);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 8u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        list.up();
        list.up();
        list.up();
        list.up();

        xassert_eq(list.go(8), bstate_t::success);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 8u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.go(7), bstate_t::success);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 7u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.go(6), bstate_t::success);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 6u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.go(5), bstate_t::success);
        xassert_eq(list->i_top, 5u);
        xassert_eq(list->i_current, 5u);
        xassert_eq(list->i_bottom, 8u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.go(4), bstate_t::success);
        xassert_eq(list->i_top, 4u);
        xassert_eq(list->i_current, 4u);
        xassert_eq(list->i_bottom, 7u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.go(3), bstate_t::success);
        xassert_eq(list->i_top, 3u);
        xassert_eq(list->i_current, 3u);
        xassert_eq(list->i_bottom, 6u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.go(2), bstate_t::success);
        xassert_eq(list->i_top, 2u);
        xassert_eq(list->i_current, 2u);
        xassert_eq(list->i_bottom, 5u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.go(1), bstate_t::success);
        xassert_eq(list->i_top, 1u);
        xassert_eq(list->i_current, 1u);
        xassert_eq(list->i_bottom, 4u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        xassert_eq(list.go(0), bstate_t::success);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 0u);
        xassert_eq(list->i_bottom, 3u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 9u);

        list = inc::text_list{}->count(3)->count_of_visiable(4u);

        xassert_eq(list.go(0), bstate_t::success);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 0u);
        xassert_eq(list->i_bottom, 2u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 3u);

        xassert_eq(list.go(1), bstate_t::success);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 1u);
        xassert_eq(list->i_bottom, 2u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 3u);

        xassert_eq(list.go(2), bstate_t::success);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 2u);
        xassert_eq(list->i_bottom, 2u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 3u);

        xassert_eq(list.go(3), bstate_t::fail);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 2u);
        xassert_eq(list->i_bottom, 2u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 3u);



        xassert_eq(list.down(), inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 0u);
        xassert_eq(list->i_bottom, 2u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 3u);

        xassert_eq(list.down(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 1u);
        xassert_eq(list->i_bottom, 2u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 3u);

        xassert_eq(list.down(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 2u);
        xassert_eq(list->i_bottom, 2u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 3u);



        xassert_eq(list.up(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 1u);
        xassert_eq(list->i_bottom, 2u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 3u);

        xassert_eq(list.up(), not inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 0u);
        xassert_eq(list->i_bottom, 2u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 3u);

        xassert_eq(list.up(), inc::text_list_rotate);
        xassert_eq(list->i_top, 0u);
        xassert_eq(list->i_current, 2u);
        xassert_eq(list->i_bottom, 2u);
        xassert_eq(list->is_ready, true);
        xassert_eq(list->count_of_visiable, 4u);
        xassert_eq(list->count, 3u);
    };
}

#endif
